<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'b_expertIntroducePicturel.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript"
	src="<%=path%>/js/jquery-1.6.2.min.js"></script>
	<style type="text/css">
		body {
     			overflow-x : hidden;   
     			overflow-y : hidden;   
		} 
	</style>

  </head>
  <script>
  
  
  function upload(){//改变文件就提交
  		 var file=document.getElementById("file").value;
	     alert(file);
	     
	     $.ajax({
			    cache: true,
				type: 'POST',
				url:'<%=path%>/Product_ProductPicture?oldPhoto=${request.fileName }',
				data:"fileName="+document.getElementById("fileName").value,	 
				async: false,
				error: function(request) {
				alert("发送请求失败！"+request.responseText);
				},
				success: function(data) {
				alert("添加成功");
				}
				});
	}
	
	function setImg() {//刷新就加载
	//	alert("213");
	   var parentVal = window.parent.a;
	    $('#myImg').attr('src','<%=path %>/img/' + parentVal);
	}
  
  
   $(function(){//第一次打开就加载
	   
     var imgName = "${request.fileName }";
      if(imgName !="") {
    	alert("你好");
   $('#myImg').attr('src','<%=path %>/img/' + imgName);
     } 
});
   

  
  
  
  </script>
  
  
  <body>
    <form name="pictureForm" id="form" action="<%=path%>/Product_ProductPicture?oldPhoto=${request.fileName }" enctype="multipart/form-data" method="post">
    	<table>
			<tr>
				<td align="left" width="250px">
					<img id="myImg" alt="缩略图" width="100px" height="140px">
				</td>
				<td>
					<input id="fileName" name="fileName" type="hidden" value="bkdjvbk" name="userImage">
				</td>
			</tr> 
			<tr>
				<td>
					<input type="file" id="file" name="file" width="50px" onchange="upload()">
				</td>
			</tr>
		</table>
    </form>
  </body>
</html>